The code defines a test suite with three test cases to add a subdomain to a load balancer, involving inserting a backend bucket, adding a frontend, and updating a URL map, with each test case having a 60-second timeout.
Alternatively, you can summarize it in two sentences:
The code is a test suite that adds a subdomain to a load balancer, consisting of three test cases to insert a backend bucket, add a frontend, and update a URL map. Each test case has a 60-second timeout and includes assertions to verify the returned values are not empty.
npm run import -- "test bucket web map"
var assert = require('assert');
var importer = require('../Core');
var {
insertBackendBucket,
insertGlobalForward,
updateUrlMap
} = importer.import("add google bucket web map");
var addIP = importer.import("check dns");
var project = 'spahaha-ea443';
var domain = 'sheet-to-web.sheet-to-web.com';
var urlMap = 'web-map';
describe('adding a subdomain to a load balancer', () => {
it('should add a bucket backend', () => {
return insertBackendBucket(project, domain)
.then(bucketName => {
assert(bucketName.length > 0, 'should have added a backend');
})
}).timeout(60000)
it('should add a frontend to load balancer', () => {
// TODO: check for A record in DNS to get ip
return addIP(project, domain)
.then(ip => insertGlobalForward(project, ip, urlMap, domain))
.then(bucketName => {
assert(bucketName.length > 0, 'should have added a forward');
})
}).timeout(60000)
it('should update url map on load balancer', () => {
return updateUrlMap(project, urlMap, domain)
.then(map => {
assert(map.length > 0, 'should have updated the map');
})
}).timeout(60000)
})
const assert = require('assert');
const importer = require('../Core');
const {
insertBackendBucket,
insertGlobalForward,
updateUrlMap
} = importer.import('add google bucket web map');
const addIP = importer.import('check dns');
const project ='spahaha-ea443';
const domain ='sheet-to-web.sheet-to-web.com';
const urlMap = 'web-map';
describe('adding a subdomain to a load balancer', () => {
// Test 1: Adding a bucket backend
it('should add a bucket backend', async () => {
const bucketName = await insertBackendBucket(project, domain);
assert(bucketName.length > 0,'should have added a backend');
}).timeout(60000);
// Test 2: Adding a frontend to load balancer
it('should add a frontend to load balancer', async () => {
const ipAddress = await addIP(project, domain);
const bucketName = await insertGlobalForward(project, ipAddress, urlMap, domain);
assert(bucketName.length > 0,'should have added a forward');
}).timeout(60000);
// Test 3: Updating url map on load balancer
it('should update url map on load balancer', async () => {
const map = await updateUrlMap(project, urlMap, domain);
assert(map.length > 0,'should have updated the map');
}).timeout(60000);
});
assert
module is required for assertions.importer
is required from a local module named ../Core
.importer
:
insertBackendBucket
insertGlobalForward
updateUrlMap
addIP
project
: The project ID (spahaha-ea443
).domain
: The domain name (sheet-to-web.sheet-to-web.com
).urlMap
: The URL map name (web-map
).The code defines a test suite for adding a subdomain to a load balancer. It consists of three test cases:
insertBackendBucket
with project
and domain
.bucketName
is not empty.addIP
with project
and domain
.addIP
.insertGlobalForward
with project
, ip
, urlMap
, and domain
.bucketName
is not empty.updateUrlMap
with project
, urlMap
, and domain
.map
is not empty.All three test cases have a timeout of 60 seconds each.